package mylibrary.encoding;

import org.apache.commons.codec.binary.Hex;


public class Tools {

	public static void main(String[] args) throws Exception {
		
		encode("高", "utf-8");
		encode("高", "utf-16");
		encode("g", "utf-8");
		encode(" ", "utf-8");
	}
	
	public static void encode(String str, String encoding) throws Exception {
		
		byte[] b = str.getBytes(encoding);
		
		System.out.print("byte number:" + b.length);
		
		char[] c = Hex.encodeHex(b);
		
		String s = new String(c);
		
		System.out.println("  " + s);
		
	}
}
